/*
 * @Description: finally和return
 * @Author: rendc
 * @Date: 2025-08-18 14:13:47
 * @LastEditors: rendc
 * @LastEditTime: 2025-08-18 14:27:18
 */

public class Test04 {

  public static void main(String[] args) {
    int r = getNum(10, 0);
    // int r2 = getNum(new Integer(10), new Integer(0));
    System.out.println("r:" + r);
    // System.out.println("r2:" + r2);
  }

  // 重载 类型不同
  public static int getNum(int a, int b) {
    System.out.println("int");
    int n = 0;
    try {
      System.out.println("try:n=" + n);
      n = a / b;
      System.out.println("try:n=" + n);
    } catch (Exception e) {
      e.printStackTrace();
      n = 20;
      System.out.println("catch:n=" + n);
      // 先建立了返回通道 n = 20；
      // 然后有一个必须要执行的finally 去执行finally n = 30
      // 但是不影响return
      // return n;
    } finally {
      n = 30;
      System.out.println("finally:n=" + n);
    }
    System.out.println("finally外:n=" + n);
    return n;
  }
  // 重载 类型不同
  // public static int getNum(Integer ia, Integer ib) {
  // System.out.println("Integer");
  // return 0;
  // }

}